/*
   Licensed to the Apache Software Foundation (ASF) under one or more
   contributor license agreements.  See the NOTICE file distributed with
   this work for additional information regarding copyright ownership.
   The ASF licenses this file to You under the Apache License, Version 2.0
   (the "License"); you may not use this file except in compliance with
   the License.  You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
*/
var showControllersOnly = false;
var seriesFilter = "";
var filtersOnlySampleSeries = true;

/*
 * Add header in statistics table to group metrics by category
 * format
 *
 */
function summaryTableHeader(header) {
    var newRow = header.insertRow(-1);
    newRow.className = "tablesorter-no-sort";
    var cell = document.createElement('th');
    cell.setAttribute("data-sorter", false);
    cell.colSpan = 1;
    cell.innerHTML = "Requests";
    newRow.appendChild(cell);

    cell = document.createElement('th');
    cell.setAttribute("data-sorter", false);
    cell.colSpan = 3;
    cell.innerHTML = "Executions";
    newRow.appendChild(cell);

    cell = document.createElement('th');
    cell.setAttribute("data-sorter", false);
    cell.colSpan = 7;
    cell.innerHTML = "Response Times (ms)";
    newRow.appendChild(cell);

    cell = document.createElement('th');
    cell.setAttribute("data-sorter", false);
    cell.colSpan = 1;
    cell.innerHTML = "Throughput";
    newRow.appendChild(cell);

    cell = document.createElement('th');
    cell.setAttribute("data-sorter", false);
    cell.colSpan = 2;
    cell.innerHTML = "Network (KB/sec)";
    newRow.appendChild(cell);
}

/*
 * Populates the table identified by id parameter with the specified data and
 * format
 *
 */
function createTable(table, info, formatter, defaultSorts, seriesIndex, headerCreator) {
    var tableRef = table[0];

    // Create header and populate it with data.titles array
    var header = tableRef.createTHead();

    // Call callback is available
    if(headerCreator) {
        headerCreator(header);
    }

    var newRow = header.insertRow(-1);
    for (var index = 0; index < info.titles.length; index++) {
        var cell = document.createElement('th');
        cell.innerHTML = info.titles[index];
        newRow.appendChild(cell);
    }

    var tBody;

    // Create overall body if defined
    if(info.overall){
        tBody = document.createElement('tbody');
        tBody.className = "tablesorter-no-sort";
        tableRef.appendChild(tBody);
        var newRow = tBody.insertRow(-1);
        var data = info.overall.data;
        for(var index=0;index < data.length; index++){
            var cell = newRow.insertCell(-1);
            cell.innerHTML = formatter ? formatter(index, data[index]): data[index];
        }
    }

    // Create regular body
    tBody = document.createElement('tbody');
    tableRef.appendChild(tBody);

    var regexp;
    if(seriesFilter) {
        regexp = new RegExp(seriesFilter, 'i');
    }
    // Populate body with data.items array
    for(var index=0; index < info.items.length; index++){
        var item = info.items[index];
        if((!regexp || filtersOnlySampleSeries && !info.supportsControllersDiscrimination || regexp.test(item.data[seriesIndex]))
                &&
                (!showControllersOnly || !info.supportsControllersDiscrimination || item.isController)){
            if(item.data.length > 0) {
                var newRow = tBody.insertRow(-1);
                for(var col=0; col < item.data.length; col++){
                    var cell = newRow.insertCell(-1);
                    cell.innerHTML = formatter ? formatter(col, item.data[col]) : item.data[col];
                }
            }
        }
    }

    // Add support of columns sort
    table.tablesorter({sortList : defaultSorts});
}

$(document).ready(function() {

    // Customize table sorter default options
    $.extend( $.tablesorter.defaults, {
        theme: 'blue',
        cssInfoBlock: "tablesorter-no-sort",
        widthFixed: true,
        widgets: ['zebra']
    });

    var data = {"OkPercent": 98.55855855855856, "KoPercent": 1.4414414414414414};
    var dataset = [
        {
            "label" : "FAIL",
            "data" : data.KoPercent,
            "color" : "#FF6347"
        },
        {
            "label" : "PASS",
            "data" : data.OkPercent,
            "color" : "#9ACD32"
        }];
    $.plot($("#flot-requests-summary"), dataset, {
        series : {
            pie : {
                show : true,
                radius : 1,
                label : {
                    show : true,
                    radius : 3 / 4,
                    formatter : function(label, series) {
                        return '<div style="font-size:8pt;text-align:center;padding:2px;color:white;">'
                            + label
                            + '<br/>'
                            + Math.round10(series.percent, -2)
                            + '%</div>';
                    },
                    background : {
                        opacity : 0.5,
                        color : '#000'
                    }
                }
            }
        },
        legend : {
            show : true
        }
    });

    // Creates APDEX table
    createTable($("#apdexTable"), {"supportsControllersDiscrimination": true, "overall": {"data": [0.48930921052631576, 500, 1500, "Total"], "isController": false}, "titles": ["Apdex", "T (Toleration threshold)", "F (Frustration threshold)", "Label"], "items": [{"data": [0.6271186440677966, 500, 1500, "模块列表接口"], "isController": false}, {"data": [0.4473684210526316, 500, 1500, "论坛列表接口"], "isController": false}, {"data": [0.16981132075471697, 500, 1500, "首页事务"], "isController": true}, {"data": [1.0, 500, 1500, "用户接口"], "isController": false}, {"data": [0.32954545454545453, 500, 1500, "用户帖子列表接口"], "isController": false}, {"data": [0.4745762711864407, 500, 1500, "登录POST请求接口"], "isController": false}, {"data": [0.696078431372549, 500, 1500, "JAVA模块接口"], "isController": false}, {"data": [0.2441860465116279, 500, 1500, "详情页响应接口"], "isController": false}, {"data": [0.3, 500, 1500, "JAVA模块详情接口"], "isController": false}, {"data": [0.6509433962264151, 500, 1500, "getAll接口"], "isController": false}, {"data": [0.25, 500, 1500, "帖子详情页接口"], "isController": false}, {"data": [0.6181818181818182, 500, 1500, "getUnreadCount接口"], "isController": false}]}, function(index, item){
        switch(index){
            case 0:
                item = item.toFixed(3);
                break;
            case 1:
            case 2:
                item = formatDuration(item);
                break;
        }
        return item;
    }, [[0, 0]], 3);

    // Create statistics table
    createTable($("#statisticsTable"), {"supportsControllersDiscrimination": true, "overall": {"data": ["Total", 555, 8, 1.4414414414414414, 2523.9945945945938, 0, 41185, 716.0, 6986.400000000001, 10339.4, 22903.83999999996, 6.851428924140485, 652.7838752237517, 1.3549751944324424], "isController": false}, "titles": ["Label", "#Samples", "FAIL", "Error %", "Average", "Min", "Max", "Median", "90th pct", "95th pct", "99th pct", "Transactions/s", "Received", "Sent"], "items": [{"data": ["模块列表接口", 59, 0, 0.0, 1280.3559322033898, 35, 6449, 382.0, 3697.0, 4575.0, 6449.0, 0.8999938983464519, 1.3245027390704132, 0.16259655390048203], "isController": false}, {"data": ["论坛列表接口", 57, 1, 1.7543859649122806, 4037.421052631579, 211, 16312, 548.0, 12311.6, 13052.799999999996, 16312.0, 0.8637541482929489, 455.170245161272, 0.16448443253625494], "isController": false}, {"data": ["首页事务", 53, 1, 1.8867924528301887, 6934.132075471697, 889, 21155, 5139.0, 18150.0, 18988.799999999996, 21155.0, 0.8051652107861754, 425.33260242593997, 0.5975835548803646], "isController": true}, {"data": ["用户接口", 44, 0, 0.0, 1.0909090909090915, 0, 3, 1.0, 2.0, 2.0, 3.0, 0.7952717479711533, 0.33854119598026283, 0.14057049451443238], "isController": false}, {"data": ["用户帖子列表接口", 44, 0, 0.0, 2594.8636363636356, 244, 8549, 1969.0, 6301.5, 7324.0, 8549.0, 0.7037072577807633, 1.9180458429293412, 0.13331953907174615], "isController": false}, {"data": ["登录POST请求接口", 59, 0, 0.0, 2974.4745762711873, 116, 12913, 928.0, 10603.0, 12576.0, 12913.0, 0.7921376976987728, 0.18985291748341881, 0.2212546949262909], "isController": false}, {"data": ["JAVA模块接口", 51, 0, 0.0, 1221.4705882352941, 98, 6175, 374.0, 4625.400000000001, 5307.5999999999985, 6175.0, 0.812787862367922, 0.2881269473042536, 0.150810247900298], "isController": false}, {"data": ["详情页响应接口", 43, 2, 4.651162790697675, 3460.5348837209303, 8, 11584, 2655.0, 7808.4, 9373.999999999998, 11584.0, 0.6772720113403685, 0.17124067274373916, 0.13420235962356275], "isController": false}, {"data": ["JAVA模块详情接口", 50, 4, 8.0, 7032.84, 187, 41185, 3515.0, 23219.399999999998, 27922.64999999999, 41185.0, 0.722564235960577, 325.49915640625454, 0.14465397301945143], "isController": false}, {"data": ["getAll接口", 53, 0, 0.0, 1106.358490566038, 101, 7187, 436.0, 2791.8000000000006, 5098.4999999999945, 7187.0, 0.8184316995583557, 0.25618215124000127, 0.14866044542759196], "isController": false}, {"data": ["帖子详情页接口", 40, 1, 2.5, 2692.175, 6, 10451, 1985.5, 6333.9, 8940.19999999999, 10451.0, 0.6926526866266082, 0.3619685243467419, 0.13183399279641206], "isController": false}, {"data": ["getUnreadCount接口", 55, 0, 0.0, 1388.4181818181821, 111, 6996, 490.0, 4151.199999999998, 5929.199999999997, 6996.0, 0.8501561195783225, 0.18016003705907813, 0.1610647335919869], "isController": false}]}, function(index, item){
        switch(index){
            // Errors pct
            case 3:
                item = item.toFixed(2) + '%';
                break;
            // Mean
            case 4:
            // Mean
            case 7:
            // Median
            case 8:
            // Percentile 1
            case 9:
            // Percentile 2
            case 10:
            // Percentile 3
            case 11:
            // Throughput
            case 12:
            // Kbytes/s
            case 13:
            // Sent Kbytes/s
                item = item.toFixed(2);
                break;
        }
        return item;
    }, [[0, 0]], 0, summaryTableHeader);

    // Create error table
    createTable($("#errorsTable"), {"supportsControllersDiscrimination": false, "titles": ["Type of error", "Number of errors", "% in errors", "% in all samples"], "items": [{"data": ["Value expected to match regexp '操作成功', but it did not match: 'Required request parameter 'id' for method parameter type Long is present but converted to null'", 1, 12.5, 0.18018018018018017], "isController": false}, {"data": ["Value expected to match regexp '操作成功', but it did not match: '\\r\\n### Error querying database.  Cause: java.sql.SQLException: Read timed out\\r\\n### The error may exist in class path resource [mapper/extension/ArticleExtMapper.xml]\\r\\n### The error may involve com.bitejiuyeke.forum.dao.ArticleMapper.selectAllByBoardId-Inline\\r\\n### The error occurred while setting parameters\\r\\n### SQL: select     u.id as u_id,     u.avatarUrl as u_avatarUrl,     u.nickname as u_nickname,     a.id,     a.boardId,     a.userId,     a.title,     a.visitCount,     a.replyCount,     a.likeCount,     a.state,     a.createTime,     a.updateTime     from     t_article a, t_user u     where     a.userId = u.id     and a.deleteState = 0     and a.boardId = ?     order by a.createTime desc\\r\\n### Cause: java.sql.SQLException: Read timed out\\n; Read timed out; nested exception is java.sql.SQLException: Read timed out'", 4, 50.0, 0.7207207207207207], "isController": false}, {"data": ["Value expected to match regexp '操作成功', but it did not match: '\\r\\n### Error querying database.  Cause: com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure\\n\\nThe last packet successfully received from the server was 10,009 milliseconds ago. The last packet sent successfully to the server was 10,282 milliseconds ago.\\r\\n### The error may exist in class path resource [mapper/extension/ArticleReplyExtMapper.xml]\\r\\n### The error may involve com.bitejiuyeke.forum.dao.ArticleReplyMapper.selectByArticleId-Inline\\r\\n### The error occurred while setting parameters\\r\\n### SQL: select     u.id as u_id,     u.avatarUrl as u_avatarUrl,     u.nickname as u_nickname,     ar.id,     ar.articleId,     ar.postUserId,     ar.replyId,     ar.replyUserId,     ar.content,     ar.likeCount,     ar.state,     ar.createTime,     ar.updateTime     from t_article_reply ar, t_user u     where ar.postUserId = u.id     and ar.articleId = ?     and ar.deleteState = 0     order by ar.createTime desc\\r\\n### Cause: com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure\\n\\nThe last packet successfully received from the server was 10,009 milliseconds ago. The last packet sent successfully to the server was 10,282 milliseconds ago.\\n; Communications link failure\\n\\nThe last packet successfully received from the server was 10,009 milliseconds ago. The last packet sent successfully to the server was 10,282 milliseconds ago.; nested exception is com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure\\n\\nThe last packet successfully received from the server was 10,009 milliseconds ago. The last packet sent successfully to the server was 10,282 milliseconds ago.'", 1, 12.5, 0.18018018018018017], "isController": false}, {"data": ["Value expected to match regexp '操作成功', but it did not match: '\\r\\n### Error querying database.  Cause: java.sql.SQLException: Read timed out\\r\\n### The error may exist in class path resource [mapper/extension/ArticleExtMapper.xml]\\r\\n### The error may involve defaultParameterMap\\r\\n### The error occurred while setting parameters\\r\\n### SQL: select     u.id as u_id,     u.avatarUrl as u_avatarUrl,     u.nickname as u_nickname,     a.id,     a.boardId,     a.userId,     a.title,     a.visitCount,     a.replyCount,     a.likeCount,     a.state,     a.createTime,     a.updateTime     from     t_article a, t_user u     where     a.userId = u.id     and a.deleteState = 0     order by a.createTime desc\\r\\n### Cause: java.sql.SQLException: Read timed out\\n; Read timed out; nested exception is java.sql.SQLException: Read timed out'", 1, 12.5, 0.18018018018018017], "isController": false}, {"data": ["Value expected to match regexp '操作成功', but it did not match: 'Required request parameter 'articleId' for method parameter type Long is present but converted to null'", 1, 12.5, 0.18018018018018017], "isController": false}]}, function(index, item){
        switch(index){
            case 2:
            case 3:
                item = item.toFixed(2) + '%';
                break;
        }
        return item;
    }, [[1, 1]]);

        // Create top5 errors by sampler
    createTable($("#top5ErrorsBySamplerTable"), {"supportsControllersDiscrimination": false, "overall": {"data": ["Total", 555, 8, "Value expected to match regexp '操作成功', but it did not match: '\\r\\n### Error querying database.  Cause: java.sql.SQLException: Read timed out\\r\\n### The error may exist in class path resource [mapper/extension/ArticleExtMapper.xml]\\r\\n### The error may involve com.bitejiuyeke.forum.dao.ArticleMapper.selectAllByBoardId-Inline\\r\\n### The error occurred while setting parameters\\r\\n### SQL: select     u.id as u_id,     u.avatarUrl as u_avatarUrl,     u.nickname as u_nickname,     a.id,     a.boardId,     a.userId,     a.title,     a.visitCount,     a.replyCount,     a.likeCount,     a.state,     a.createTime,     a.updateTime     from     t_article a, t_user u     where     a.userId = u.id     and a.deleteState = 0     and a.boardId = ?     order by a.createTime desc\\r\\n### Cause: java.sql.SQLException: Read timed out\\n; Read timed out; nested exception is java.sql.SQLException: Read timed out'", 4, "Value expected to match regexp '操作成功', but it did not match: 'Required request parameter 'id' for method parameter type Long is present but converted to null'", 1, "Value expected to match regexp '操作成功', but it did not match: '\\r\\n### Error querying database.  Cause: com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure\\n\\nThe last packet successfully received from the server was 10,009 milliseconds ago. The last packet sent successfully to the server was 10,282 milliseconds ago.\\r\\n### The error may exist in class path resource [mapper/extension/ArticleReplyExtMapper.xml]\\r\\n### The error may involve com.bitejiuyeke.forum.dao.ArticleReplyMapper.selectByArticleId-Inline\\r\\n### The error occurred while setting parameters\\r\\n### SQL: select     u.id as u_id,     u.avatarUrl as u_avatarUrl,     u.nickname as u_nickname,     ar.id,     ar.articleId,     ar.postUserId,     ar.replyId,     ar.replyUserId,     ar.content,     ar.likeCount,     ar.state,     ar.createTime,     ar.updateTime     from t_article_reply ar, t_user u     where ar.postUserId = u.id     and ar.articleId = ?     and ar.deleteState = 0     order by ar.createTime desc\\r\\n### Cause: com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure\\n\\nThe last packet successfully received from the server was 10,009 milliseconds ago. The last packet sent successfully to the server was 10,282 milliseconds ago.\\n; Communications link failure\\n\\nThe last packet successfully received from the server was 10,009 milliseconds ago. The last packet sent successfully to the server was 10,282 milliseconds ago.; nested exception is com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure\\n\\nThe last packet successfully received from the server was 10,009 milliseconds ago. The last packet sent successfully to the server was 10,282 milliseconds ago.'", 1, "Value expected to match regexp '操作成功', but it did not match: '\\r\\n### Error querying database.  Cause: java.sql.SQLException: Read timed out\\r\\n### The error may exist in class path resource [mapper/extension/ArticleExtMapper.xml]\\r\\n### The error may involve defaultParameterMap\\r\\n### The error occurred while setting parameters\\r\\n### SQL: select     u.id as u_id,     u.avatarUrl as u_avatarUrl,     u.nickname as u_nickname,     a.id,     a.boardId,     a.userId,     a.title,     a.visitCount,     a.replyCount,     a.likeCount,     a.state,     a.createTime,     a.updateTime     from     t_article a, t_user u     where     a.userId = u.id     and a.deleteState = 0     order by a.createTime desc\\r\\n### Cause: java.sql.SQLException: Read timed out\\n; Read timed out; nested exception is java.sql.SQLException: Read timed out'", 1, "Value expected to match regexp '操作成功', but it did not match: 'Required request parameter 'articleId' for method parameter type Long is present but converted to null'", 1], "isController": false}, "titles": ["Sample", "#Samples", "#Errors", "Error", "#Errors", "Error", "#Errors", "Error", "#Errors", "Error", "#Errors", "Error", "#Errors"], "items": [{"data": [], "isController": false}, {"data": ["论坛列表接口", 57, 1, "Value expected to match regexp '操作成功', but it did not match: '\\r\\n### Error querying database.  Cause: java.sql.SQLException: Read timed out\\r\\n### The error may exist in class path resource [mapper/extension/ArticleExtMapper.xml]\\r\\n### The error may involve defaultParameterMap\\r\\n### The error occurred while setting parameters\\r\\n### SQL: select     u.id as u_id,     u.avatarUrl as u_avatarUrl,     u.nickname as u_nickname,     a.id,     a.boardId,     a.userId,     a.title,     a.visitCount,     a.replyCount,     a.likeCount,     a.state,     a.createTime,     a.updateTime     from     t_article a, t_user u     where     a.userId = u.id     and a.deleteState = 0     order by a.createTime desc\\r\\n### Cause: java.sql.SQLException: Read timed out\\n; Read timed out; nested exception is java.sql.SQLException: Read timed out'", 1, "", "", "", "", "", "", "", ""], "isController": false}, {"data": [], "isController": false}, {"data": [], "isController": false}, {"data": [], "isController": false}, {"data": [], "isController": false}, {"data": [], "isController": false}, {"data": ["详情页响应接口", 43, 2, "Value expected to match regexp '操作成功', but it did not match: '\\r\\n### Error querying database.  Cause: com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure\\n\\nThe last packet successfully received from the server was 10,009 milliseconds ago. The last packet sent successfully to the server was 10,282 milliseconds ago.\\r\\n### The error may exist in class path resource [mapper/extension/ArticleReplyExtMapper.xml]\\r\\n### The error may involve com.bitejiuyeke.forum.dao.ArticleReplyMapper.selectByArticleId-Inline\\r\\n### The error occurred while setting parameters\\r\\n### SQL: select     u.id as u_id,     u.avatarUrl as u_avatarUrl,     u.nickname as u_nickname,     ar.id,     ar.articleId,     ar.postUserId,     ar.replyId,     ar.replyUserId,     ar.content,     ar.likeCount,     ar.state,     ar.createTime,     ar.updateTime     from t_article_reply ar, t_user u     where ar.postUserId = u.id     and ar.articleId = ?     and ar.deleteState = 0     order by ar.createTime desc\\r\\n### Cause: com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure\\n\\nThe last packet successfully received from the server was 10,009 milliseconds ago. The last packet sent successfully to the server was 10,282 milliseconds ago.\\n; Communications link failure\\n\\nThe last packet successfully received from the server was 10,009 milliseconds ago. The last packet sent successfully to the server was 10,282 milliseconds ago.; nested exception is com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure\\n\\nThe last packet successfully received from the server was 10,009 milliseconds ago. The last packet sent successfully to the server was 10,282 milliseconds ago.'", 1, "Value expected to match regexp '操作成功', but it did not match: 'Required request parameter 'articleId' for method parameter type Long is present but converted to null'", 1, "", "", "", "", "", ""], "isController": false}, {"data": ["JAVA模块详情接口", 50, 4, "Value expected to match regexp '操作成功', but it did not match: '\\r\\n### Error querying database.  Cause: java.sql.SQLException: Read timed out\\r\\n### The error may exist in class path resource [mapper/extension/ArticleExtMapper.xml]\\r\\n### The error may involve com.bitejiuyeke.forum.dao.ArticleMapper.selectAllByBoardId-Inline\\r\\n### The error occurred while setting parameters\\r\\n### SQL: select     u.id as u_id,     u.avatarUrl as u_avatarUrl,     u.nickname as u_nickname,     a.id,     a.boardId,     a.userId,     a.title,     a.visitCount,     a.replyCount,     a.likeCount,     a.state,     a.createTime,     a.updateTime     from     t_article a, t_user u     where     a.userId = u.id     and a.deleteState = 0     and a.boardId = ?     order by a.createTime desc\\r\\n### Cause: java.sql.SQLException: Read timed out\\n; Read timed out; nested exception is java.sql.SQLException: Read timed out'", 4, "", "", "", "", "", "", "", ""], "isController": false}, {"data": [], "isController": false}, {"data": ["帖子详情页接口", 40, 1, "Value expected to match regexp '操作成功', but it did not match: 'Required request parameter 'id' for method parameter type Long is present but converted to null'", 1, "", "", "", "", "", "", "", ""], "isController": false}, {"data": [], "isController": false}]}, function(index, item){
        return item;
    }, [[0, 0]], 0);

});
